import {ConfigEnv, loadEnv, UserConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import svgLoader from 'vite-svg-loader'
import path from "path";

const CWD = process.cwd();

// https://vitejs.dev/config/
export default ({mode}: ConfigEnv): UserConfig => {
    const {VITE_BASE_PATH, VITE_SERVER_URL} = loadEnv(mode, CWD);
    // //console.log("【VITE_BASE_PATH】", VITE_SERVER_URL)
    // //console.log("【VITE_SERVER_URL】", VITE_SERVER_URL)
    return {
        //
        base: VITE_BASE_PATH,
        //
        resolve: {
            alias: {
                '@': path.resolve(__dirname, './src'),
            },
        },
        //插件
        plugins: [
            vue(),
            // Components({
            // resolvers: [AntDesignVueResolver()],
            // }),
            // viteMockServe({
            //     mockPath: 'mock',
            //     localEnabled: true,
            // }),
            svgLoader()
        ],
        //
        server: {
            port: 3002,
            host: '0.0.0.0',
            cors: true,
            open: true,
            // proxy: {
            //     '/': VITE_SERVER_URL,
            // },
        },
        //
        build: {},
        //
        css: {
            preprocessorOptions: {
                less: {
                    javascriptEnabled: true,
                    modifyVars: {
                        hack: `true; @import (reference) "${path.resolve('src/common/style/theme.less')}";`,
                    }
                }
            }
        },
    };
};


//
// // https://vitejs.dev/config/
// export default defineConfig({
//     plugins: [

//
//     ],
//     resolve: {
//         alias: {
//             '@': path.resolve(__dirname, './src'),
//         },
//     },
// })
//
//
